<?php
/**
 * Customer Admin List View
 */
?>
<div class="header">
	<h2>Customer Admin</h2>
	<div class="add">
		<a href="<?= $this->routeUrl("admin_customer_add") ?>">Create New Customer</a>
	</div>
	<div style="clear:both"></div>
</div>
<div id="customeradmin">
	<table class="admin">
		<thead>
			<tr>
				<?php // @todo This needs to use the get params in routeUrl ?>
				<th><a href="<?= $this->routeUrl("admin_customer_list", null, array('order' => 'customer_id', 'dir' => $this->dir)) ?>">ID</a></th>
				<th><a href="<?= $this->routeUrl("admin_customer_list", null, array('order' => 'lastname', 'dir' => $this->dir)) ?>">Customer</a></th>
				<th><a href="<?= $this->routeUrl("admin_customer_list", null, array('order' => 'email', 'dir' => $this->dir)) ?>">E-mail</a></th>
				<th><a href="<?= $this->routeUrl("admin_customer_list", null, array('order' => 'last_login', 'dir' => $this->dir)) ?>">Last Login</a></th>
				<th><a href="<?= $this->routeUrl("admin_customer_list", null, array('order' => 'user_role', 'dir' => $this->dir)) ?>">Role</a></th>
				<th><a href="<?= $this->routeUrl("admin_customer_list", null, array('order' => 'is_active', 'dir' => $this->dir)) ?>">Active?</a></th>
				<th> &nbsp; </th>
			</tr>
		</thead>
		<tbody>
			<?php foreach ($this->customers as $customer): ?>
				<?php
					$last_login = strtotime($customer['last_login'])
				?>
				<tr class="customer <?= $this->cycle(array("odd", "even"))->next() ?>">
					<th class="customer_id"><?= $this->e($customer['customer_id']) ?></th>
					<td class="name"><a href="<?= $this->routeUrl("admin_customer_edit", array('customer_id' => $customer['customer_id'])) ?>"><?= $this->e($customer['lastname']) ?>, <?= $this->e($customer['firstname']) ?></a></td>
					<td class="email"><?= $this->e($customer['email']) ?></td>
					<td class="last_login">
						<?= $this->e(ucfirst($this->humanize()->naturalDay($last_login))) ?>
						<?= $this->e($this->humanize()->naturalTime($last_login)) ?>
					</td>
					<td class="user_role"><?= $this->e($customer['user_role']) ?></td>
					<td class="is_active"><?= $this->e($customer['is_active']) ?></td>
					<td class="admin">
						<a href="<?= $this->routeUrl("admin_customer_edit", array('customer_id' => $customer['customer_id'])) ?>">Edit</a>&nbsp;|&nbsp;
						<a href="<?= $this->routeUrl("admin_customer_delete", array('customer_id' => $customer['customer_id'])) ?>" onclick="return confirm('Are you sure you want to delete this customer?')">Delete</a>
					</td>
				</tr>
			<?php endforeach ?>
		</tbody>
	</table>
	
	<?= $this->paginationControl($this->customers) ?>

</div> <!-- /#customeradmin -->